﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HandleClient
{
    class Program
    {
        public static void Main()
        {
            var client = new TcpPacketClient();

            try
            {
                // 连接服务器
                client.Connect("127.0.0.1", 13000);

                // 发送测试数据
                //client.SendPacket(0x01, "Hello Server!");
                //client.SendPacket(0x02, "Another message");
                Task.Run( async () =>
                {
                    while (true)
                    {
                        await Task.Delay(TimeSpan.FromSeconds(5));
                        client.SendPacket(0x00,"heart packet");
                        
                    }
                });

                // 保持连接
                Console.WriteLine("Press ENTER to exit...");
                Console.ReadLine();
            }
            finally
            {
                client.Disconnect();
            }

            Console.Read();
        }
    }
}
